import { defineStore } from "pinia";
import { ref } from "vue";
import { DoctorList, DoctorPage, PageParams } from "@/types/homeTypes";
import { fetchFollowDoctorListAPI } from "@/api/homeApi.ts";

const useHomeStore = defineStore("homeStore", () => {
    const followDoctorList = ref<DoctorList>([]);
    const fetchDoctorList = async (params: PageParams): Promise<void> => {
        const { data }: { data: DoctorPage } = await fetchFollowDoctorListAPI(params);
        followDoctorList.value = data.rows;
    };

    return {
        followDoctorList,
        fetchDoctorList,
    };
});

export default useHomeStore;
